<?php
$server = "localhost";
$user = "root";
$pwd = "root";
$database = "tur";
//
//$ulinix = mysqli_connect($servar, $user, $pwd, $database);
//if ($ulinix) {
//    $query = "create table tur(id int primary key unique not null,name varchar(50) not null,passwrd1 varchar(50) not null,passwrd2 varchar(50) not null,selfintroduction varchar(300))";
//    $queryok = mysqli_query($ulinix, $query);
//    if ($queryok) {
//        echo "数据表创建成功";
//    } else {
//        echo "数据表创建失败";
//        echo mysqli_errno($ulinix);
//    }
//} else {
//    echo "数据库链接失败";
//}
$name = $_POST['username'];
$password1 = $_POST['pwd1'];
$password2= $_POST['pwd2'];
$age = $_POST['age'];
$sex = $_POST['sex'];
$tel = $_POST['tel'];
$description = $_POST['description'];
$hobby = $_POST['hobby'];
$hometown=$_POST['hometown'];



$ulinix = mysqli_connect($server, $user, $pwd, $database);
if ($ulinix) {
    echo "数据库链接成功";
$hobby = implode("#",$_POST['hobby']);
    $query=" insert into tur(name,password1,password2,age,sex,tel,hometown,hobby,description) values('".$name."','".$password1."','".$password2."',".$age.",'".$sex."','".$tel."',".$hometown.",'".$hobby."','".$description."')";
    echo $query;
    $queryok=mysqli_query($ulinix,$query);
      if ($queryok) {
        echo "数据添加成功";
    } else {
        echo "数据添加失败". mysqli_error($ulinix);
    }
} else {
    echo "数据库链接失败".mysqli_connect_error();

}
echo "<br>";
echo "<a href='table.php'>查看信息</a>";
